#include <iostream>
#include <vector>
using namespace std;

vector<vector<int>> ans;
vector<int> track;
int bucket;

void dfs(int start, int k, int n){
    if(bucket == n && track.size() == k){
        ans.push_back(track);
        return;
    }
    for(int i=start;i<=9;i++){
        if(start > n - bucket) continue;
        bucket += i;
        track.push_back(i);
        dfs(i+1, k, n);
        bucket -= i;
        track.pop_back();
    }
    return;
}

vector<vector<int>> combinationSum3(int k, int n) {
    dfs(0, k, n);
    return ans;
}